/**
 * @file
 * @author Filipe Mutz
 *
 * @section DESCRIPTION
 *
 */
#include "distribution.h"

#include <cmath>
#include <cstdlib>

namespace brain
{
	namespace distribution
	{
		Distribution::Distribution()
		{
		}


		Distribution::~Distribution()
		{
		}


		GaussianDistribution::GaussianDistribution(Point center, double deviation)
		{
			_center = center;

			for(unsigned int i = 0; i < _center.size(); i++)
				_deviation.push_back(deviation);
		}


		GaussianDistribution::GaussianDistribution(Point center, Point deviation)
		{
			_center = center;
			_deviation = deviation;
		}


		GaussianDistribution::~GaussianDistribution()
		{
			_center.clear();
			_deviation.clear();
		}


		vector<Point>
		GaussianDistribution::generate(int num_points)
		{
			vector<Point> distribution;

			//
			// The first element is always the center! I've done it to not lost the reference to the center.
			// I know, I know it's not that elegant, but I could not found a better solution right now.
			//

			distribution.push_back(_center);
			num_points--;

			for(int i = 0; i < num_points; i++)
			{
				Point p;

				for(unsigned int j = 0; j < _center.size(); j++)
					p.push_back(_center[j] + random_gaussian_radius(_deviation[j]));

				distribution.push_back(p);
			}

			return distribution;
		}
	}
}
